<?php include("db.php");

// If user is not logged in
if (!isset($_SESSION['userid'])) {

	// Check if they came from the login page
	if (isset($_POST['username']) && isset($_POST['password'])) {
		user_login($_POST['username'], $_POST['password']);

	// If not, then redirect them to the login page
	} 
	else {
		echo "You must log-in before accessing this resource";
		include("loginpage.php");
		exit();
	}
}

if ($_SESSION['type'] == 2) {
	include("admin/AdminMainPage.php");
} else if ($_SESSION['type'] == 1) {
	include("main.php");
}

 
?>
